<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:sijyp="http://fiscalia.gov/sijyp">

<cc:interface>
	<cc:attribute name="prefixId" required="true"
		shortDescription="Cadena de texto como prefijo a los ids para evitar duplicados" />
	<cc:attribute name="label" required="false" default="Persona"
		shortDescription="Label del campo de persona" />
	<cc:attribute name="value" required="true"
		shortDescription="Propiedad que tendrá el nombre de la persona seleccionada en el popUp de búsqueda de personas" />
	<cc:attribute name="dto" required="true"
		shortDescription="DTO que maneja la pantalla los datos" />
	<cc:attribute name="required" required="false" default="false"
		shortDescription="Booleano que especifica si el campo es o no requerido" />
	<cc:attribute name="disabled" required="false" default="false"
		shortDescription="Determina si se inhabilita el campo, ocultando la lupa" />
	<cc:attribute name="styleClass" required="false"
		default="long longPersona"
		shortDescription="Clase que indica si el input es largo o corto" />
	<cc:attribute name="requiredMessage" required="false" default="#{msgVal['constraint.not_null']}" shortDescription="Required Message" />
</cc:interface>

<cc:implementation>

	<c:if test="#{cc.attrs.label != null or cc.attrs.label != ''}">
		<h:panelGrid columns="2">
			<h:outputLabel value="#{cc.attrs.label}"  />		
		</h:panelGrid>
	</c:if>
	<h:panelGrid columns="2">
		<h:panelGrid id="#{cc.attrs.prefixId}PersonInputPanel">
			<h:inputText id="#{cc.attrs.prefixId}PersonNameInput"
				value="#{cc.attrs.value}" styleClass="#{cc.attrs.styleClass}"
				disabled="true" />
			<h:inputHidden id="#{cc.attrs.prefixId}PersonName"
				value="#{cc.attrs.value}" required="#{cc.attrs.required}"
				rendered="#{not cc.attrs.disabled}"
				requiredMessage="#{cc.attrs.requiredMessage}" />
			<h:message for="#{cc.attrs.prefixId}PersonName"
				errorClass="validationErrorMessage" showSummary="false" />
		</h:panelGrid>

		<h:commandLink disabled="#{cc.attrs.disabled}"
			onclick="#{rich:component(sijyp:concat(cc.attrs.prefixId,'Popup'))}.show()"
			action="#{personasManager.clearAndSetDto(cc.attrs.dto)}">
			<h:graphicImage value="/resources/images/icons/ico_lupa.png"
				title="#{cc.attrs.label}" />
			<f:ajax execute="@this"
				render="#{sijyp:concat(cc.attrs.prefixId,'PopupComponent')}:personasPopUpHeader #{sijyp:concat(cc.attrs.prefixId,'PopupComponent')}:personasPopUpForm" />
		</h:commandLink>
	</h:panelGrid>

</cc:implementation>
</html>